package org.spp.voronoi;

import org.spp.utilities.Point;

/**
 * Plane.java
 * @author Ilio Catallo, Eleonora Ciceri
 * @version 1.0
 * @see Facet
 * 
 * Description: class that implements the facet in the case of tridimensional
 *              vector spaces. In such a case the facet is a plane.
 * 
 * Date: Jun 10, 2011
 */
public class Plane extends Facet{
    
    /**
     * Constructor for the class Plane
     * @param a
     * @param b
     * @param c
     * @param d
     * @param inBoundedRegion 
     */
    public Plane(Double a, Double b, Double c, Double d, boolean inBoundedRegion){        
        super(new double[]{a, b, c, d}, inBoundedRegion);     
    } 

    /**
     * Constructor for the class Plane
     * @param a
     * @param b
     * @param c
     * @param d
     * @param inBoundedRegion 
     */
    public Plane(double[] coefficients, boolean inBoundedRegion){        
        super(coefficients, inBoundedRegion);      
    }     
    
    /**
     * Constructor for the class Plane
     * @param firstCentroid
     * @param secondCentroid 
     */
    public Plane(Centroid firstCentroid, Centroid secondCentroid) {  
        
        super(firstCentroid, secondCentroid);
        this.coefficients = new double[4];
        
        // Variables
        double[] mediumPoint = firstCentroid.computeMediumPoint(secondCentroid);
        double[] normal = firstCentroid.computeVectorToPoint(secondCentroid);
                        
        // Store the coefficients of the plane
        this.coefficients[0] = normal[0];
        this.coefficients[1] = normal[1];
        this.coefficients[2] = normal[2];
        this.coefficients[3] = Point.dotProduct(normal, mediumPoint);  
    }
    
}
